package ipad.asia.controller;

import ipad.asia.entity.Enterprise;
import ipad.asia.entity.Order;
import ipad.asia.service.consumer.ConsumerFeign;
import ipad.asia.service.enterprise.EnterpriseFeign;
import ipad.asia.service.order.OrderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@RestController
public class SocketToAjaxController {
    @Autowired
    private OrderFeign orderFeign;
    @Autowired
    private ConsumerFeign consumerFeign;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private EnterpriseFeign enterpriseFeign;


    //JSON化参数
    @RequestMapping(value = "ajax/userName")
    public String name(HttpServletResponse response,HttpServletRequest request) {
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));//处理跨域
        response.setHeader("Access-Control-Allow-Credentials", "true");//表示是否允许发送Cookie
       if(request.getSession().getAttribute("user")==null){
           return "登录过期，请重新登录";
       }
        return (String) request.getSession().getAttribute("user");
    }
}
